"""
查询女生的总数
"""

import pymysql
from pymysql.cursors import DictCursor

conn = pymysql.connect(
    host='localhost',
    port=3306,
    user='root',
    password='6666',
    database='homework'
)
try:
    cursor=conn.cursor(DictCursor)
    sql = """
        select * from student
    """
    ret_num = cursor.execute(sql)
    result = cursor.fetchall()
    # print(result)
    count = 0
    for stu in result:
        if stu['Sex']== '女':
            count += 1
    print(count)

except:
    conn.rollback()
